import '../../../../resource/component/css/component_v2_pc.css'
import '../common/common.scss';

import Vue from 'vue';

import Loading from 'packages/BaseLoading'
import StatsChartEmpty from '../common/StatsChartEmpty.vue';
import { Popover, Table, TableColumn, Pagination, Dropdown, DropdownItem, DropdownMenu, Checkbox, Tooltip} from 'element-ui';
import StatsPopverIcon from '../common/StatsPopoverIcon.vue';
import StationView from './StationView.vue';

import http from 'src/util/HttpUtil';
import filters from '@src/filter/filter';

import * as mtracker from '../../../util/Mtrackers';
import DatePicker from '../common/DataTime.vue'

import { isOpenData } from '@src/util/platform';
import platformExtension from '@src/platform/extension'

mtracker.initializeTalkingData();

for(let name in filters) Vue.filter(name, filters[name]);

Vue.prototype.$loading = Loading;
Vue.prototype.$http = http;
Vue.prototype.$tdOnEvent = mtracker.onEvent;

Vue.component(DatePicker.name, DatePicker)
Vue.component(StatsChartEmpty.name, StatsChartEmpty);
Vue.component(Popover.name, Popover);
Vue.component(Table.name, Table);
Vue.component(TableColumn.name, TableColumn);
Vue.component(Dropdown.name, Dropdown);
Vue.component(DropdownItem.name, DropdownItem);
Vue.component(DropdownMenu.name, DropdownMenu);
Vue.component(Checkbox.name, Checkbox);
Vue.component(Pagination.name, Pagination);
Vue.component(Tooltip.name, Tooltip);
Vue.component(StatsPopverIcon.name, StatsPopverIcon);

const isQYWX = window.wx || isOpenData
// const signPromise = isQYWX ? platformExtension.sign() : Promise.resolve()
const signPromise = Promise.resolve()

Vue.component('async-station-view', function (resolve, reject) {
  try {
    signPromise
      .then(result => {
        resolve(StationView)
      })
      .catch(err => {
        resolve(StationView)
      })
  } catch (error) {
    resolve(StationView)
  }
})

let app = {
  render(h) {
    return <async-station-view />
  }
}

export default app;